package 测试;

import java.util.ArrayList;
import java.util.Scanner;

public class 奇数位丢弃 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			int n = Integer.parseInt(sc.next());
			System.out.println(func(n));
		}
		sc.close();
	}

	public static int func(int n) {
		ArrayList<Integer> al = new ArrayList<Integer>();
		for (int i = 0; i <= n; i++) {
			al.add(i);
		}
		while (al.size() != 1) {
			for (int i = 0; i < al.size(); i++) {
				al.remove(i);
			}
		}
		return al.get(0);
	}

}
